
package net.swa.index.util;

import java.util.Arrays;
import net.swa.util.DateUtils;
import net.swa.util.EncryptTool;

public class WxStringUtil
{

    /**
     * 调用wxapi接口参数生成
     * @param wxid2
     * @param gzhId2
     * @return
     * @throws Exception
     */
    public static String getSuffix(String wxid2 , String gzhId2) throws Exception
    {
        long ts = DateUtils.getCurrDate().getTime();
        String[] array = { wxid2, Long.toString(ts), gzhId2 };
        Arrays.sort(array);
        String str = "";
        for (String s : array)
        {
            str += s;
        }
        EncryptTool tool = new EncryptTool();
        String token = tool.encrypt(str);
        String r = "?wxid=" + wxid2 + "&gzhId=" + gzhId2 + "&ts=" + ts + "&token=" + token;
        return r;
    }
}
